package org.activequant.core.domainmodel.data;

import static org.activequant.util.tools.IdentityUtils.equalsTo;
import static org.activequant.util.tools.IdentityUtils.safeCompare;
import static org.activequant.util.tools.IdentityUtils.safeHashCode;

import org.activequant.core.domainmodel.InstrumentSpecification;

public class TickerNews  extends MarketDataEntity<TickerNews> {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4565484698810658915L;
	/**
	 * private String title = null;
	 */
	private String title = null;
	/**
	 * private String link = null;
	 */
	private String link = null;
	/**
	 * private String description = null;
	 */
	private String description = null;
	/**
	 * returns the associated title(String)
	 * @return
	 */
	public String getTitle() {
		return title;
	}
	/**
	 * sets the associated title(String) with the given title(String)
	 * @param exchange
	 */
	public void setTitle(String title) {
		this.title = title;
	}
	/**
	 * returns the associated link(String)
	 * @return
	 */
	public String getLink() {
		return link;
	}
	/**
	 * sets the associated link(String) with the given link(String)
	 * @param exchange
	 */
	public void setLink(String link) {
		this.link = link;
	}
	/**
	 * returns the associated description(String)
	 * @return
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * sets the associated description(String) with the given description(String)
	 * @param exchange
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * empty TickerNews constructor
	 */
	public TickerNews() {

	}
	/**
	 * constructs a TickerNews(MarketDataEntity subclass) and sets its associated/inherited instrumentSpecification(InstrumentSpecification) with the given spec(InstrumentSpecification)
	 * @param spec
	 */
	public TickerNews(InstrumentSpecification spec) {
		setInstrumentSpecification(spec);
	}

	@Override
	public TickerNews clone() {
		TickerNews clone=new TickerNews(getInstrumentSpecification());
		clone.setTitle(getTitle());
		clone.setDescription(getDescription());
		clone.setLink(getLink());
		clone.setTimeStamp(getTimeStamp());
		return clone;
	}

    /**
     * {@inheritDoc}
     */
	public int compareTo(TickerNews other) {
		// ATTENTION: keep in sync with hashCode();
		int rc;
		
		if((rc = safeCompare(getInstrumentSpecification(), other.getInstrumentSpecification())) != 0) {
			return rc;
		}
		if((rc = safeCompare(this.getTimeStamp(), other.getTimeStamp())) != 0) {
			return rc;
		}
		if((rc = safeCompare(this.getTitle() , other.getTitle())) != 0) {
			return rc;
		}
		if((rc = safeCompare(this.getLink() , other.getLink())) != 0) {
			return rc;
		}
		return 0;
	}

    /**
     * {@inheritDoc}
     */
    @Override
	public int hashCode() {
		// ATTENTION: keep in sync with comapreTo();
        return safeHashCode(getInstrumentSpecification())
        	+ safeHashCode(this.getTimeStamp())
        	+ safeHashCode(this.getTitle())
        	+ safeHashCode(this.getLink());
	}
	
    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object other) {
    	// NOTE: delegates to compareTo()
    	return equalsTo(this, other);
	}
}
